Skip to content

Add per-source telemetry for package IDs containing non-ASCII characters#7213

Open
Copilot wants to merge 5 commits intodevfrom
copilot/add-telemetry-package-id-validation
Open

Add per-source telemetry for package IDs containing non-ASCII characters#7213
Copilot wants to merge 5 commits intodevfrom
copilot/add-telemetry-package-id-validation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

Bug

Fixes: NuGet/Home#14212

Description

Adds telemetry to track whether any package ID contains characters outside [A-Za-z0-9.\-] (i.e., anything other than ASCII letters, digits, ., or -). This is emitted in two places:

  1. Per-source (PackageSourceDiagnostics event) — correlates non-standard ID usage to specific feed providers
  2. Per-restore (ProjectRestoreInformation event) — indicates whether any resolved package in the restore graph has a non-standard ID

Protocol layer

  • Added PackageId property to ProtocolDiagnosticNupkgCopiedEvent (nullable; new 3-param constructor, old 2-param delegates to it)
  • Updated all four raise-sites to pass the package ID:
    • FindPackagesByIdNupkgDownloaderidentity.Id
    • LocalPackageArchiveDownloader_packageIdentity.Id
    • LocalV3FindPackageByIdResource / LocalV2FindPackageByIdResourceid parameter
  • New public API declared in both PublicAPI.Unshipped.txt files

Per-source telemetry (PackageSourceTelemetry)

  • Data class: new IdContainsNonAsciiCharacter bool, sticky-true once any non-standard ID is seen for that source
  • Detection uses a zero-allocation ReadOnlySpan<char> character loop (local function HasNonASCIICharacters)
  • AddNupkgCopiedData: skips check when PackageId is null (events raised by old constructor)
  • ToTelemetryAsync: emits nupkgs.idcontainsnonasciicharacter alongside the existing nupkgs.copied / nupkgs.bytes

Per-restore telemetry (RestoreCommand)

  • New AnyPackageIdContainsNonASCIICharacters property on the ProjectRestoreInformation telemetry event
  • Scans all resolved packages across non-conflicting restore graphs using the same character-check logic (local function)
  • Only emitted for non-NoOp restores (NoOp returns before this code runs)

Tests

PackageSourceTelemetryTests — Existing tests covering AddNupkgCopiedData for: all-standard IDs → false; non-standard IDs (underscore, Unicode, space, @, +) → true; mixed batch with one non-standard → sticky true; null PackageIdfalse. ToTelemetry_WithData_CreatesTelemetryProperties asserts the new property is emitted.

RestoreCommandTests — New tests:

  • ExecuteAsync_WithASCIIPackageId_AnyPackageIdContainsNonASCIICharactersIsFalse — standard [A-Za-z0-9.-] package → false
  • ExecuteAsync_WithNonASCIIPackageId_AnyPackageIdContainsNonASCIICharactersIsTrue[Theory] with underscore, Kelvin sign (U+212A), Greek alpha (U+03B1), accented Latin (U+00E9), Cyrillic (U+0410) → true
  • ExecuteAsync_WithMixedPackageIds_AnyPackageIdContainsNonASCIICharactersIsTrue[Theory] where direct dep is standard but transitive dep has non-standard chars → true
  • Updated existing exhaustive telemetry tests to include the new property

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

Copilot AI changed the title [WIP] Add telemetry for non-standard package ID tracking Add per-source telemetry for non-standard package ID characters Mar 13, 2026
Copilot AI requested a review from jeffkl March 13, 2026 17:32
Copilot AI requested a review from jeffkl March 16, 2026 20:04
@jeffkl jeffkl changed the title Add per-source telemetry for non-standard package ID characters Add per-source telemetry for package IDs containing non-ASCII characters Mar 16, 2026
Copilot AI requested a review from jeffkl March 16, 2026 20:11
@dotnet-policy-service dotnet-policy-service bot added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Mar 23, 2026
Copilot AI and others added 5 commits March 30, 2026 10:50
… per feed source

Co-authored-by: jeffkl <17556515+jeffkl@users.noreply.github.com>
Co-authored-by: jeffkl <17556515+jeffkl@users.noreply.github.com>
Co-authored-by: jeffkl <17556515+jeffkl@users.noreply.github.com>
@jeffkl jeffkl force-pushed the copilot/add-telemetry-package-id-validation branch from 7e34992 to 79664c2 Compare March 30, 2026 20:12
@jeffkl jeffkl marked this pull request as ready for review March 30, 2026 20:12
@jeffkl jeffkl requested a review from a team as a code owner March 30, 2026 20:12
@jeffkl jeffkl requested a review from donnie-msft March 30, 2026 20:12
@dotnet-policy-service dotnet-policy-service bot removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants